package com.androidx.p013lv.base.p015ui;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.inputmethod.InputMethodManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidx.p013lv.base.BaseApp;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.utils.ActivityUtil;
import com.grass.p019lv.R;
import com.gyf.immersionbar.ImmersionBar;

import cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper;

/* renamed from: com.androidx.lv.base.ui.BaseActivity */
public abstract class BaseActivity<T extends ViewDataBinding>
        extends AppCompatActivity implements BGASwipeBackHelper.Delegate {
    public T binding;
    private boolean clickLimit = true;
    private long lastClickTime;
    protected BGASwipeBackHelper mSwipeBackHelper;
    /* access modifiers changed from: protected */
    public Context getActivity() {
        return this;
    }

    /* access modifiers changed from: protected */
    public void initData() {
    }

    /* access modifiers changed from: protected */
    public void initView() {
    }

    @Override // p012cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper.Delegate
    public boolean isSupportSwipeBack() {
        return true;
    }

    @Override // p012cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper.Delegate
    public void onSwipeBackLayoutCancel() {
    }

    @Override // p012cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper.Delegate
    public void onSwipeBackLayoutSlide(float f) {
    }

    public abstract int setLayout();

    /* access modifiers changed from: protected */
    @Override // androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        initSwipeBackFinish();
        super.onCreate(bundle);
        if (BaseApp.flag == -1) {
            protectApp();
            return;
        }
        getWindow().addFlags(128);
        ActivityUtil.getInstance().addActivity(this);
        ARouter.getInstance().inject(this);
        T t = (T) DataBindingUtil.setContentView(this, setLayout());
        this.binding = t;
        t.setLifecycleOwner(this);
        initView();
        initImmersionBar();
        initData();
    }

    /* access modifiers changed from: protected */
    public void protectApp() {
        ARouter.getInstance().build(Constance.MAIN_ACTIVITY).addFlags(67108864).navigation();
        finish();
    }

    private void initSwipeBackFinish() {
        BGASwipeBackHelper bGASwipeBackHelper = new BGASwipeBackHelper(this, this);
        this.mSwipeBackHelper = bGASwipeBackHelper;
        bGASwipeBackHelper.setSwipeBackEnable(true);
        this.mSwipeBackHelper.setIsOnlyTrackingLeftEdge(true);
        this.mSwipeBackHelper.setIsWeChatStyle(true);
        this.mSwipeBackHelper.setShadowResId(R.color.picture_color_ffd042);
        this.mSwipeBackHelper.setIsNeedShowShadow(true);
        this.mSwipeBackHelper.setIsShadowAlphaGradient(true);
        this.mSwipeBackHelper.setSwipeBackThreshold(0.3f);
        this.mSwipeBackHelper.setIsNavigationBarOverlap(false);
    }

    @Override // p012cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper.Delegate
    public void onSwipeBackLayoutExecuted() {
        this.mSwipeBackHelper.swipeBackward();
    }

    @Override // androidx.activity.ComponentActivity
    public void onBackPressed() {
        if (!this.mSwipeBackHelper.isSliding()) {
            this.mSwipeBackHelper.backward();
        }
    }

    /* access modifiers changed from: protected */
    public void initImmersionBar() {
        ImmersionBar.with(this).statusBarDarkFont(false).navigationBarDarkIcon(false).autoDarkModeEnable(true).keyboardEnable(false).init();
    }

    @SuppressLint("WrongConstant")
    public boolean onTouchEvent(MotionEvent motionEvent) {
        if (getCurrentFocus() != null) {
            return ((InputMethodManager) getSystemService("input_method")).hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
        }
        return super.onTouchEvent(motionEvent);
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity
    public void onDestroy() {
        ActivityUtil.getInstance().removeActivity(this);
        super.onDestroy();
    }

    /* access modifiers changed from: protected */
    public boolean isOnClick() {
        long currentTimeMillis = System.currentTimeMillis();
        long j = currentTimeMillis - this.lastClickTime;
        if (j > 1000) {
            this.lastClickTime = currentTimeMillis;
        }
        return !this.clickLimit ? j < 0 : j <= 1000;
    }

    public void startVideoPlay(int i) {
        ARouter.getInstance().build(Constance.VIDEO_PLAY_ACTIVITY).withSerializable(Key.VIDEO_ID, Integer.valueOf(i)).navigation();
    }

    public boolean isDestroy() {
        if (!isFinishing()) {
            return Build.VERSION.SDK_INT >= 17 && isDestroyed();
        }
        return true;
    }
}
